<#import "/ftl/pager.ftl" as pager/>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title><@spring.message "module.common.html.title"/></title>
<#include "/resources.html">
<script>
function showMessageDialog(account){
  $('#messageDialog').modal('show');
  $('#Saccount').val(account);
}

function doSendMessage(){
    var message = $('#message').val();
    var account = $('#Saccount').val();
    if($.trim(message)=='')
    {
       return;
    }
    showProcess("<@spring.message 'module.dashboard.cimsession.sending'/>");
    $.post("/dashboard/message/send.action", {content:message,action:2,sender:'system',receiver:account,format:'0'},
	   function(data){
	   
	      hideProcess();
	      showSTip("<@spring.message 'module.dashboard.cimsession.send.success'/>");
	      doHideDialog("messageDialog");
     });
}

</script>
</head>
<body class="web-app ui-selectable">

<#include "/dashboard/header.html">
<#include "/dashboard/nav.html">

<div id="mainWrapper">

	<div class="lay-main-toolbar"></div>
	<div>
		<form action="/dashboard/session/list.action" method="post" id="searchForm" >
			<input type="hidden" name="currentPage" id="currentPage" value="0"/>
			<table style="width: 100%" class="utable">
				<thead>
					<tr class="tableHeader">
						<th width="5%"><@spring.message 'module.dashboard.cimsession.logo'/></th>
						<th width="8%"><@spring.message 'module.dashboard.cimsession.account'/></th>
						<th width="6%"> <@spring.message 'module.dashboard.cimsession.nid'/></th>
						<th width="6%"><@spring.message 'module.dashboard.cimsession.channel'/></th>
						<th width="14%"><@spring.message 'module.dashboard.cimsession.deviceid'/></th>
						<th width="10%"><@spring.message 'module.dashboard.cimsession.device.model'/></th>
						<th width="6%"><@spring.message 'module.dashboard.cimsession.app.version'/></th>
						<th width="6%"><@spring.message 'module.dashboard.cimsession.os.version'/></th>
						<th width="6%"><@spring.message 'module.dashboard.cimsession.online.time'/></th>
						<th width="25%"><@spring.message 'module.common.location'/></th>
						<th width="8%"><@spring.message "module.common.operation"/></th>
					</tr>
                          <tr>
                            <td></td>
							<td>
								<input name="account" type="text" value="${cimsession.account! }"class="form-control" style="margin: 3px 0px;height: 32px;" />
							</td>
							<td>
							 	<input name="nid" type="number"  value="<#if cimsession.nid??>${cimsession.nid?c}</#if>"class="form-control" style="margin: 3px 0px;height: 32px;" />
							</td>
							<td>
								<select name="channel" class="form-control" style="width: 100%;padding：6px;">
									<option />
									<option value="android" <#if 'android' == cimsession.channel! > selected="selected"</#if>>Android</option>
									<option value="ios" <#if 'ios' == cimsession.channel!> selected="selected"</#if>>IOS</option>
									<option value="browser" <#if 'browser' == cimsession.channel!> selected="selected"</#if>>Browser</option>
								</select>
							</td>
							<td>
								<input name="deviceId" type="text" value="${cimsession.deviceId! }" class="form-control" style="margin: 3px 0px;height: 32px;" />
							</td>
							<td>
								<input name="deviceModel" type="text" value="${cimsession.deviceModel! }" class="form-control" style="margin: 3px 0px;height: 32px;" />
							</td>
							<td>
								<input name="clientVersion" type="text" value="${cimsession.clientVersion! }" class="form-control" style="margin: 3px 0px;height: 32px;" />
							</td>
							<td>
								<input name="systemVersion" type="text" value="${cimsession.systemVersion! }" class="form-control" style="margin: 3px 0px;height: 32px;" />
							</td>
							<td></td>
							<td></td>
							<td>
								<button type="submit" class="btn btn-primary btn-sm">
									<span class="glyphicon glyphicon-search"></span>
									<@spring.message "module.common.query"/>
								</button>
							</td>
						</tr>
				</thead>
				<tbody>
               		<#list page.content as cimsession>
						<tr style="height: 50px;">
						    <td></td>
						    <td>${cimsession.account! }</td>
							<td><#if cimsession.nid??>${cimsession.nid?c}</#if></td>
							<td>${cimsession.channel! }</td>
							<td>${cimsession.deviceId! }</td>
							<td>${cimsession.deviceModel! }</td>
							<td>${cimsession.clientVersion! }</td>
	                        <td>${cimsession.systemVersion! }</td>
							<td>
								<@spring.messageArgs  "module.dashboard.cimsession.time.format",[((.now?long - cimsession.bindTime)/1000)?round?c]  />
							</td>
							<td>${cimsession.location!}</td>
							<td>
								<div class="btn-group btn-group-xs">
									<button type="button" class="btn btn-primary" style="padding: 5px;" onclick="showMessageDialog('${cimsession.account!}')">
										<span class="glyphicon glyphicon-send" style="top:2px;"></span>
										<@spring.message 'module.dashboard.cimsession.send.message'/>
									</button>
								</div>
							</td>
				 		</tr>
					</#list>
				</tbody>
                <tfoot>
					<tr>
						<td colspan="11"><@pager.pager page=page/></td>
					</tr>
				</tfoot>
			</table>
		</form>
	</div>
</div>
<div class="modal fade" id="messageDialog" tabindex="-1" role="dialog" >
	<div class="modal-dialog" style="width: 420px;">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title"><@spring.message 'module.dashboard.cimsession.send.message'/></h4>
			</div>
			<div class="modal-body">
				<div class="form-groupBuy">
					<label for="Amobile">
						<@spring.message 'module.dashboard.cimsession.receiver'/>
					</label>
					<input type="text" class="form-control" id="Saccount" name="account"
						style="width: 100%; font-size: 20px; font-weight: bold;height:40px;"
						disabled="disabled" />
				</div>
				<div class="form-groupBuy" style="margin-top: 20px;">
					<label for="exampleInputFile">
						<@spring.message 'module.dashboard.cimsession.message'/>
					</label>
					<textarea rows="10" style="width: 100%; height: 200px;" id="message" name="message" class="form-control"></textarea>
				</div>
			</div>
			<div class="modal-footer" style="padding: 5px 10px; text-align: center;">
				<button type="button" class="btn btn-success btn-lg" style="width: 200px;" onclick="doSendMessage()">
					<span class="glyphicon glyphicon-send" style="top:2px;"></span><@spring.message 'module.common.send'/>
				</button>
			</div>
		</div>
	</div>
</div>

<script>
$('#sessionMenu').addClass('current');
</script>
</body>
</html>
